// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_FIN_MAP_BPA_PD
// * CreateDate    : 2012/2/2 10:17:12
// * Creater       : CodeSmith
// * LastChangeDate: 2012/2/2 10:17:12
// * LastChanger   : 2012/2/2 10:17:12
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Fin
{
/// <summary>
    /// FinMapBpaPd
    /// </summary>
    public partial class FinMapBpaPdBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objFinMapBpaPdEntity">Entity</param>
        /// <returns>Entity</returns>
        public static FinMapBpaPdEntity GetFinMapBpaPd(FinMapBpaPdEntity objFinMapBpaPdEntity)
        {
            return DataAccess.SelectSingle<FinMapBpaPdEntity>(objFinMapBpaPdEntity);
        }
        public static List<FinMapBpaPdEntity> GetByApplicationID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            FinMapBpaPdEntity entity = new FinMapBpaPdEntity();
            entity.ApplicationId = id;
            return DataAccess.Select<FinMapBpaPdEntity>(entity);
        }
        public static List<FinMapBpaPdEntity> GetByPaidDetailID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            FinMapBpaPdEntity entity = new FinMapBpaPdEntity();
            entity.PaidDetailId = id;
            return DataAccess.Select<FinMapBpaPdEntity>(entity);
        }
        public static List<InvImportOrderEntity> GetImportOrderByPaidDetailID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            string sql = @"SELECT IMP.*
                            FROM FIN_PAID_DETAIL PD
                            INNER JOIN FIN_MAP_BPA_PD MAP ON MAP.PAID_DETAIL_ID = PD.PAID_DETAIL_ID
                            INNER JOIN FIN_BILLING_PAID_APPLICATION BPA ON MAP.APPLICATION_ID = BPA.APPLICATION_ID
                            INNER JOIN FIN_MAP_IO_BPA MAP2 ON MAP2.APPLICATION_ID = BPA.APPLICATION_ID
                            INNER JOIN INV_IMPORT_ORDER IMP ON IMP.IMPORT_ORDER_ID = MAP2.IMPORT_ORDER_ID
                            WHERE PD.PAID_DETAIL_ID = '" + id + "'";
            return DataAccess.Select<InvImportOrderEntity>(sql);
        }
        public static List<FinBillingPaidApplicationEntity> GetBillingAppByPaidDetailID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            string sql = @"SELECT BPA.*
                            FROM FIN_PAID_DETAIL PD
                            INNER JOIN FIN_MAP_BPA_PD MAP ON MAP.PAID_DETAIL_ID = PD.PAID_DETAIL_ID
                            INNER JOIN FIN_BILLING_PAID_APPLICATION BPA ON MAP.APPLICATION_ID = BPA.APPLICATION_ID
                            WHERE PD.PAID_DETAIL_ID = '" + id + "'";
            return DataAccess.Select<FinBillingPaidApplicationEntity>(sql);
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objFinMapBpaPdEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertFinMapBpaPd(FinMapBpaPdEntity objFinMapBpaPdEntity)
        {
            return DataAccess.Insert(objFinMapBpaPdEntity);
        }

        public static bool InsertFinMapBpaPd(List<FinMapBpaPdEntity> objFinMapBpaPdEntityList)
        {
            return DataAccess.Insert(objFinMapBpaPdEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objFinMapBpaPdEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateFinMapBpaPd(FinMapBpaPdEntity objFinMapBpaPdEntity)
        {
            return DataAccess.Update(objFinMapBpaPdEntity);
        }

        public static bool UpdateFinMapBpaPd(List<FinMapBpaPdEntity> objFinMapBpaPdEntityList)
        {
            return DataAccess.Update<FinMapBpaPdEntity>(objFinMapBpaPdEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objFinMapBpaPdEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteFinMapBpaPd(FinMapBpaPdEntity objFinMapBpaPdEntity)
        {
            return DataAccess.Delete(objFinMapBpaPdEntity);
        }

        public static bool DeleteFinMapBpaPd(List<FinMapBpaPdEntity> objFinMapBpaPdEntityList)
        {
            return DataAccess.Delete<FinMapBpaPdEntity>(objFinMapBpaPdEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetFinMapBpaPdAll()
        {
            return DataAccess.SelectAllDataSet<FinMapBpaPdEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<FinMapBpaPdEntity> GetFinMapBpaPdAllList()
        {
            return DataAccess.SelectAll<FinMapBpaPdEntity>();
        }
        #endregion
	}
	
	
}	

